<template>
  <div>
    <div class="toolbar">
      <el-form :inline="true" class="demo-form-inline">
        <el-form-item>
          <el-input placeholder="商品名称" v-model="searchgoodsTypeName"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary">查询</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="success" @click="goodsVisible=true">添加商品</el-button>
        </el-form-item>
      </el-form>
    </div>

    <el-table
      v-loading="$store.state.loading"
      :data="$store.state.goods.goodsList"
      style="width: 100%"
    >
      <el-table-column label="店铺名称" width="100">
        <template slot-scope="scope">{{scope.row.shopName}}</template>
      </el-table-column>
      <el-table-column label="商品名称" width="100">
        <template slot-scope="scope">{{scope.row.shopTypeName}}</template>
      </el-table-column>
      <el-table-column label="商品类别名称" width="120">
        <template slot-scope="scope">{{scope.row.goodsTypeName}}</template>
      </el-table-column>
      <el-table-column label="商品id" width="230">
        <template slot-scope="scope">{{scope.row._id}}</template>
      </el-table-column>
      <el-table-column label="商品图片" width="180">
        <template slot-scope="scope">
          <a :href="scope.row.goodsPic | imgUrl" :title="scope.row.goodsName" target="_blank">
            <img height="80px" :src="scope.row.goodsPic | imgUrl" alt />
          </a>
        </template>
      </el-table-column>

      <el-table-column label="商品添加时间" width="200">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.createTime | date}}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" type="danger" @click="deleteList(scope.row._id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <GoodsDialog v-if="goodsVisible" :goodsVisible.sync="goodsVisible"></GoodsDialog>
    <PageInfo action-name="getGoodsList" :params="{goodsName:searchgoodsTypeName}"></PageInfo>
  </div>
</template>


<script>
import GoodsDialog from "@/components/dialog/GoodsDialog";
export default {
  name: "goods-list",
  components: {
    GoodsDialog
  },
  data() {
    return {
      searchgoodsTypeName: "",
      goodsVisible: false
    };
  },
  methods: {
    deleteList() {
      alert("对不起,此商品暂不支持删除功能");
    }
  }
};
</script>